﻿using Microsoft.EntityFrameworkCore;
using ServerSide.Model;


namespace ServerSide.EFCoreContext
{
    public class MyDBContext : DbContext
    {
        //public DbSet<OpcuaNode> OpcuaNode { get; set; }

        public DbSet<User> User { get; set; }
        public DbSet<Role> Role { get; set; }
        public DbSet<Menu> Menu { get; set; }
        public DbSet<RoleMenu> RoleMenu { get; set; }
        public DbSet<UserRole> UserRole { get; set; }
        public MyDBContext(DbContextOptions<MyDBContext> options) : base(options)
        {
        }
        //优先级最高，使用他之后就不会注入IOC容器了
        //protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
        //{
        //    var configuration = new ConfigurationBuilder().AddJsonFile("appsettings.json");
        //    var config = configuration.Build();
        //    var connectionString = config.GetConnectionString("SqliteConnection");
        //    optionsBuilder.UseSqlite(connectionString);
        //}
        ////protected override void OnModelCreating(ModelBuilder modelBuilder)
        ////{
        ////    modelBuilder.UseCollation("utf8_general_ci");
        ////    modelBuilder.Entity<OpcuaNode>(entity =>
        ////    {
        ////        entity.ToTable("OpcuaNode");
        ////    });
        ////}

    }
}
